package com.firefightingiot.firefightingiot.web.service;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import com.firefightingiot.firefightingiot.common.base.BaseService;
import com.firefightingiot.firefightingiot.model.DeviceType;
import com.firefightingiot.firefightingiot.model.UseDict;
import com.firefightingiot.firefightingiot.support.mybatisplus.QueryWrapper;
import com.firefightingiot.firefightingiot.support.utils.DayUtil;
import com.firefightingiot.firefightingiot.support.utils.MyLogger;
import com.firefightingiot.firefightingiot.web.domain.DeviceAlarmLogDo;
import com.firefightingiot.firefightingiot.web.domain.DeviceAlarmSmallLogDo;
import com.firefightingiot.firefightingiot.web.mapper.*;
import com.firefightingiot.firefightingiot.web.mapper.alarmtoday.*;
import com.firefightingiot.firefightingiot.web.mapper.statistics.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;


@Service
@Slf4j
public class HomeDataService extends BaseService {

    @Resource
    public MyLogger logger;

    @Resource
    private DeviceBusinessMapper deviceBusinessMapper;
    @Resource
    private DeviceAlarmLogMapper deviceAlarmLogMapper;
    @Resource
    private DeviceAlarmLogImgMapper deviceAlarmLogImgMapper;

    @Resource
    private DeviceAlarmLogAllTodayMapper deviceAlarmLogAllTodayMapper;
    @Resource
    private DeviceAlarmLogElectricFireTodayMapper deviceAlarmLogElectricFireTodayMapper;
    @Resource
    private DeviceAlarmLogFireWaterTodayMapper deviceAlarmLogFireWaterTodayMapper;
    @Resource
    private DeviceAlarmLogGasTodayMapper deviceAlarmLogGasTodayMapper;
    @Resource
    private DeviceAlarmLogSmokeTodayMapper deviceAlarmLogSmokeTodayMapper;
    @Resource
    private DeviceAlarmLogVisualizationTodayMapper deviceAlarmLogVisualizationTodayMapper;
    @Resource
    private DeviceAlarmLogAllStatisticsWeekMapper deviceAlarmLogAllStatisticsWeekMapper;
    @Resource
    private DeviceAlarmLogElectricFireStatisticsWeekMapper deviceAlarmLogElectricFireStatisticsWeekMapper;
    @Resource
    private DeviceAlarmLogFireWaterStatisticsWeekMapper deviceAlarmLogFireWaterStatisticsWeekMapper;
    @Resource
    private DeviceAlarmLogGasStatisticsWeekMapper deviceAlarmLogGasStatisticsWeekMapper;
    @Resource
    private DeviceAlarmLogSmokeStatisticsWeekMapper deviceAlarmLogSmokeStatisticsWeekMapper;
    @Resource
    private DeviceAlarmLogVisualizationStatisticsWeekMapper deviceAlarmLogVisualizationStatisticsWeekMapper;
    @Resource
    private DeviceAlarmLogAllStatisticsMonthMapper deviceAlarmLogAllStatisticsMonthMapper;
    @Resource
    private DeviceAlarmLogFireExtinguisherStatisticsWeekMapper deviceAlarmLogFireExtinguisherStatisticsWeekMapper;
    @Resource
    private DeviceAlarmLogElectricFireStatisticsMonthMapper deviceAlarmLogElectricFireStatisticsMonthMapper;
    @Resource
    private DeviceAlarmLogFireWaterStatisticsMonthMapper deviceAlarmLogFireWaterStatisticsMonthMapper;
    @Resource
    private DeviceAlarmLogGasStatisticsMonthMapper deviceAlarmLogGasStatisticsMonthMapper;
    @Resource
    private DeviceAlarmLogSmokeStatisticsMonthMapper deviceAlarmLogSmokeStatisticsMonthMapper;
    @Resource
    private DeviceAlarmLogVisualizationStatisticsMonthMapper deviceAlarmLogVisualizationStatisticsMonthMapper;
    @Resource
    private DeviceAlarmLogFireExtinguisherStatisticsMonthMapper deviceAlarmLogFireExtinguisherStatisticsMonthMapper;
    @Resource
    private DeviceAlarmLogAutoNetworkStatisticsWeekMapper deviceAlarmLogAutoNetworkStatisticsWeekMapper;
    @Resource
    private DeviceAlarmLogAutoNetworkStatisticsMonthMapper deviceAlarmLogAutoNetworkStatisticsMonthMapper;
    @Resource
    private DeviceAlarmLogWaterImmersionStatisticsWeekMapper deviceAlarmLogWaterImmersionStatisticsWeekMapper;
    @Resource
    private DeviceAlarmLogWaterImmersionStatisticsMonthMapper deviceAlarmLogWaterImmersionStatisticsMonthMapper;

    //月数据保存
    public void insertMonth(String tableOne, String tableTwo, String deviceClassify) {
        JSONObject jsonParam = new JSONObject();
        //获取月初的日期
        String startDate = DayUtil.getMonthStart(new Date());
        jsonParam.put("startDate", startDate);
        jsonParam.put("table", tableOne);
        jsonParam.put("monthFlag", "1");
        jsonParam.put("deviceClassify", deviceClassify);
        List<Map<String, Object>> insertList = getInsertListForAll(jsonParam);
        jsonParam.put("table", tableTwo);
        insertList(insertList, jsonParam);
    }

    //周数据保存
    public void insertWeek(String tableOne, String tableTwo, String deviceClassify) {
        JSONObject jsonParam = new JSONObject();
        //获取七天前的日期
        String startDate = DayUtil.getPastDate(5);
        String endDate = DateUtil.now();
        jsonParam.put("startDate", startDate);
        jsonParam.put("endDate", endDate);
        jsonParam.put("table", tableOne);
        jsonParam.put("weekFlag", "1");
        jsonParam.put("deviceClassify", deviceClassify);
        List<Map<String, Object>> insertList = getInsertListForAll(jsonParam);
        jsonParam.put("table", tableTwo);
        insertList(insertList, jsonParam);
    }

    //每天往统计表塞入数据
    public void insertToday(String tableOne, String tableTwo, String deviceClassify) {
        JSONObject jsonParam = new JSONObject();
        //获取月初的日期
        String startDate = DayUtil.getYestoday();
        jsonParam.put("startDate", startDate);
        jsonParam.put("table", tableOne);
        jsonParam.put("dayFlag", "1");
        jsonParam.put("deviceClassify", deviceClassify);
        List<Map<String, Object>> insertList = getInsertListForAll(jsonParam);
        jsonParam.put("table", tableTwo);
        insertList(insertList, jsonParam);
    }

    /**
     * 第一次往日志分析表中塞数据
     *
     * @param
     * @return
     */
    public void insertLogStatisticsForOne() throws InterruptedException {
        boolean isOneNumber = DayUtil.isFewOfMonth("01");
        //查询全部日志数据月分析统计表
        int allStatisticsMonthCount = deviceAlarmLogAllStatisticsMonthMapper.selectCount(new QueryWrapper<>());
        if (allStatisticsMonthCount == 0 && !isOneNumber) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_all_statistics_month", null);
        }
        //查询全部日志数据周分析统计表
        int allStatisticsWeekCount = deviceAlarmLogAllStatisticsWeekMapper.selectCount(new QueryWrapper<>());
        if (allStatisticsWeekCount == 0) {//说明没有数据
            insertWeek("device_alarm_log", "device_alarm_log_all_statistics_week", null);
        }
        //查询电气火灾日志数据月分析统计表
        int eleMonthCount = deviceAlarmLogElectricFireStatisticsMonthMapper.selectCount(new QueryWrapper<>());
        if (eleMonthCount == 0 && !isOneNumber) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_electric_fire_statistics_month", "1");
        }
        //查询电气火灾日志数据周分析统计表
        int eleWeekCount = deviceAlarmLogElectricFireStatisticsWeekMapper.selectCount(new QueryWrapper<>());
        if (eleWeekCount == 0) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_electric_fire_statistics_week", "1");
        }
        //查询建筑消防用水日志数据月分析统计表
        int waterMonthCount = deviceAlarmLogFireWaterStatisticsMonthMapper.selectCount(new QueryWrapper<>());
        if (waterMonthCount == 0 && !isOneNumber) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_fire_water_statistics_month", "2");
        }
        //查询建筑消防用水日志数据周分析统计表
        int waterWeekCount = deviceAlarmLogFireWaterStatisticsWeekMapper.selectCount(new QueryWrapper<>());
        if (waterWeekCount == 0) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_fire_water_statistics_week", "2");
        }
        //查询烟感日志数据月分析统计表
        int smokeMonthCount = deviceAlarmLogSmokeStatisticsMonthMapper.selectCount(new QueryWrapper<>());
        if (smokeMonthCount == 0 && !isOneNumber) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_smoke_statistics_month", "3");
        }
        //查询可燃气体日志数据周分析统计表
        int smokeWeekCount = deviceAlarmLogSmokeStatisticsWeekMapper.selectCount(new QueryWrapper<>());
        if (smokeWeekCount == 0) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_smoke_statistics_week", "3");
        }
        //查询可燃气体日志数据月分析统计表
        int gasMonthCount = deviceAlarmLogGasStatisticsMonthMapper.selectCount(new QueryWrapper<>());
        if (gasMonthCount == 0 && !isOneNumber) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_gas_statistics_month", "4");
        }
        //查询可燃气体日志数据周分析统计表
        int gasWeekCount = deviceAlarmLogGasStatisticsWeekMapper.selectCount(new QueryWrapper<>());
        if (gasWeekCount == 0) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_gas_statistics_week", "4");
        }
        //查询自动联网日志数据月分析统计表
        int autoMonthCount = deviceAlarmLogAutoNetworkStatisticsMonthMapper.selectCount(new QueryWrapper<>());
        if (autoMonthCount == 0 && !isOneNumber) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_auto_network_statistics_month", "5");
        }
        //查询自动联网日志数据周分析统计表
        int autoWeekCount = deviceAlarmLogAutoNetworkStatisticsWeekMapper.selectCount(new QueryWrapper<>());
        if (autoWeekCount == 0) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_auto_network_statistics_week", "5");
        }
        //查询可视化日志数据月分析统计表
        int visMonthCount = deviceAlarmLogVisualizationStatisticsMonthMapper.selectCount(new QueryWrapper<>());
        if (visMonthCount == 0 && !isOneNumber) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_visualization_statistics_month", "6");
        }
        //查询可视化日志数据周分析统计表
        int visWeekCount = deviceAlarmLogVisualizationStatisticsWeekMapper.selectCount(new QueryWrapper<>());
        if (visWeekCount == 0) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_visualization_statistics_week", "6");
        }
        //查询灭火器日志数据月分析统计表
        int fireExtinguisherMonthCount = deviceAlarmLogFireExtinguisherStatisticsMonthMapper.selectCount(new QueryWrapper<>());
        if (fireExtinguisherMonthCount == 0 && !isOneNumber) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_fire_extinguisher_statistics_month", "7");
        }
        //查询灭火器日志数据周分析统计表
        int fireExtinguisherWeekCount = deviceAlarmLogFireExtinguisherStatisticsWeekMapper.selectCount(new QueryWrapper<>());
        if (fireExtinguisherWeekCount == 0) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_fire_extinguisher_statistics_week", "7");
        }
        //查询水浸日志数据周分析统计表
        int waterImmersionWeekCount = deviceAlarmLogWaterImmersionStatisticsWeekMapper.selectCount(new QueryWrapper<>());
        if (waterImmersionWeekCount == 0) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_water_immersion_statistics_week", "20");
        }
        //查询水浸日志数据月分析统计表
        int waterImmersionMonthCount = deviceAlarmLogWaterImmersionStatisticsMonthMapper.selectCount(new QueryWrapper<>());
        if (waterImmersionMonthCount == 0) {//说明没有数据
            insertMonth("device_alarm_log", "device_alarm_log_water_immersion_statistics_month", "20");
        }
    }

    /**
     * 每天往日志分析表中塞数据
     *
     * @param
     * @return
     */
    public void insertLogStatisticsForToday() throws InterruptedException {
        //查询全部日志数据月分析统计表
        insertToday("device_alarm_log_all_today", "device_alarm_log_all_statistics_month", null);
        //查询全部日志数据周分析统计表
        insertToday("device_alarm_log_all_today", "device_alarm_log_all_statistics_week", null);
        //查询电气火灾日志数据月分析统计表
        insertToday("device_alarm_log_electric_fire_today", "device_alarm_log_electric_fire_statistics_month", "1");
        //查询电气火灾日志数据周分析统计表
        insertToday("device_alarm_log_electric_fire_today", "device_alarm_log_electric_fire_statistics_week", "1");
        //查询建筑消防用水日志数据月分析统计表
        insertToday("device_alarm_log_fire_water_today", "device_alarm_log_fire_water_statistics_month", "2");
        //查询建筑消防用水日志数据周分析统计表
        insertToday("device_alarm_log_fire_water_today", "device_alarm_log_fire_water_statistics_week", "2");
        //查询烟感日志数据月分析统计表
        insertToday("device_alarm_log_smoke_today", "device_alarm_log_smoke_statistics_month", "3");
        //查询可燃气体日志数据周分析统计表
        insertToday("device_alarm_log_smoke_today", "device_alarm_log_smoke_statistics_week", "3");
        //查询可燃气体日志数据月分析统计表
        insertToday("device_alarm_log_gas_today", "device_alarm_log_gas_statistics_month", "4");
        //查询可燃气体日志数据周分析统计表
        insertToday("device_alarm_log_gas_today", "device_alarm_log_gas_statistics_week", "4");
        //查询自动联网日志数据月分析统计表
        insertToday("device_alarm_log_auto_network_today", "device_alarm_log_auto_network_statistics_month", "5");
        //查询自动联网日志数据周分析统计表
        insertToday("device_alarm_log_auto_network_today", "device_alarm_log_auto_network_statistics_week", "5");
        //查询可视化日志数据月分析统计表
        insertToday("device_alarm_log_visualization_today", "device_alarm_log_visualization_statistics_month", "6");
        //查询可视化日志数据周分析统计表
        insertToday("device_alarm_log_visualization_today", "device_alarm_log_visualization_statistics_week", "6");
        //查询灭火器日志数据月分析统计表
        insertToday("device_alarm_log_fire_extinguisher_today", "device_alarm_log_fire_extinguisher_statistics_month", "7");
        //查询灭火器日志数据周分析统计表
        insertToday("device_alarm_log_fire_extinguisher_today", "device_alarm_log_fire_extinguisher_statistics_week", "7");
        //查询水浸日志数据月分析统计表
        insertToday("device_alarm_log_water_immersion_today", "device_alarm_log_water_immersion_statistics_month", "20");
        //查询水浸日志数据周分析统计表
        insertToday("device_alarm_log_water_immersion_today", "device_alarm_log_water_immersion_statistics_week", "20");
    }

    @Resource
    UseDictMapper useDictMapper;
    @Resource
    DeviceTypeMapper deviceTypeMapper;

    //查询需要添加的数据
    public List<Map<String, Object>> getInsertListForAll(JSONObject jsonParam) {
        List<Map<String, Object>> insertList = new ArrayList<>();
        //日志表查询日期区间内的数据
        List<DeviceAlarmLogDo> monthLogList = new ArrayList<>();
        List<UseDict> useDicts = null;
        if (StrUtil.isBlank(jsonParam.getStr("deviceClassify"))) {
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getAllLogForStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("1")) {
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatistics(jsonParam);
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "电气火灾监测报警类型"));
        } else if (jsonParam.getStr("deviceClassify").equals("2")) {
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatistics(jsonParam);
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "建筑消防用水报警类型"));
        } else if (jsonParam.getStr("deviceClassify").equals("3")) {
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "智慧独立烟感报警类型"));
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("4")) {
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "可燃气体监测报警类型"));
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("5")) {
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "自动联网报警类型"));
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("6")) {
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "消防可视化监测报警类型"));
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("7")) {
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "智能灭火器报警类型"));
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatistics(jsonParam);
        }else if (jsonParam.getStr("deviceClassify").equals("20")) {
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "水浸监测报警类型"));
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatistics(jsonParam);
        }
        Map<String, String> keyMap = new HashMap<>();
        if (useDicts != null) {
            for (UseDict use : useDicts) {
                keyMap.put(use.getName(), use.getId());
            }
        }
        //循环处理数据
        for (DeviceAlarmLogDo deviceAlarmLogDo : monthLogList) {
            Map<String, Object> map = new HashMap<>();
            map.put("alldate", deviceAlarmLogDo.getAlldate());
            map.put("allId", deviceAlarmLogDo.getAllId());
            map.put("businessId", deviceAlarmLogDo.getBusinessId());
            map.put("date", deviceAlarmLogDo.getDate());
            map.put("orgId", deviceAlarmLogDo.getOrgId());
            List<DeviceAlarmSmallLogDo> twoList = deviceAlarmLogDo.getTwoList();
            map = getMapByTwoList(twoList, map, jsonParam.getStr("deviceClassify"), keyMap, jsonParam);
            insertList.add(map);
        }
        return insertList;
    }


    public Map<String, Object> getMapByTwoList(List<DeviceAlarmSmallLogDo> twoList, Map<String, Object> map, String deviceClassify, Map<String, String> keyMap, JSONObject jsonParam) {
        if (StrUtil.isBlank(deviceClassify)) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todayOtherCount = 0;//其他数目
                Integer todayFireCount = 0;//电气火灾报警数目
                Integer todayWaterCount = 0;//消防用水报警数目
                Integer todaySmokeCount = 0;//烟感报警数目
                Integer todayGasCount = 0;//气体报警数目
                Integer todaySmartEyeCount = 0;//慧眼识别报警数目
                Integer todayFireExtinguisherCount = 0;//灭火器报警数目
                Integer todayWaterImmersionCount = 0;//水浸报警数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals("1")) {
                        todayFireCount = todayFireCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals("2")) {
                        todayWaterCount = todayWaterCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals("3")) {
                        todaySmokeCount = todaySmokeCount + deviceAlarmSmallLogDo.getCount();
                    }else if (deviceAlarmSmallLogDo.getType().equals("4")) {
                        todayGasCount = todayGasCount + deviceAlarmSmallLogDo.getCount();
                    }else if (deviceAlarmSmallLogDo.getType().equals("6")) {
                        todaySmartEyeCount = todaySmartEyeCount + deviceAlarmSmallLogDo.getCount();
                    }else if (deviceAlarmSmallLogDo.getType().equals("7")) {
                        todayFireExtinguisherCount = todayFireExtinguisherCount + deviceAlarmSmallLogDo.getCount();
                    }else if (deviceAlarmSmallLogDo.getType().equals("20")) {
                        todayWaterImmersionCount = todayWaterImmersionCount + deviceAlarmSmallLogDo.getCount();
                    } else {
                        todayOtherCount = todayOtherCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todayFireCount", todayFireCount);
                map.put("todayWaterCount", todayWaterCount);
                map.put("todaySmokeCount", todaySmokeCount);
                map.put("todayOtherCount", todayOtherCount);
                map.put("todayGasCount", todayGasCount);
                map.put("todaySmartEyeCount", todaySmartEyeCount);
                map.put("todayFireExtinguisherEyeCount", todayFireExtinguisherCount);
                map.put("todayWaterImmersionCount", todayWaterImmersionCount);
                map.put("allCount", todayFireCount + todayWaterCount + todaySmokeCount + todayOtherCount + todayGasCount + todaySmartEyeCount + todayFireExtinguisherCount + todayWaterImmersionCount);
            } else {
                Integer allCount = 0;//总数目
                Integer weeOtherCount = 0;//其他数目
                Integer weeFileCount = 0;//电气火灾报警数目
                Integer weeWaterCount = 0;//消防用水报警数目
                Integer weeSmokeCount = 0;//烟感报警数目
                Integer weeGasCount = 0;//气体报警数目
                Integer weeSmartEyeCount = 0;//慧眼识别报警数目
                Integer weeFireExtinguisherCount = 0;//灭火器报警数目
                Integer weeWaterImmersionCount = 0;//水浸报警数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals("1")) {
                        weeFileCount = weeFileCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals("2")) {
                        weeWaterCount = weeWaterCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals("3")) {
                        weeSmokeCount = weeSmokeCount + deviceAlarmSmallLogDo.getCount();
                    }else if (deviceAlarmSmallLogDo.getType().equals("4")) {
                        weeGasCount = weeGasCount + deviceAlarmSmallLogDo.getCount();
                    }else if (deviceAlarmSmallLogDo.getType().equals("6")) {
                        weeSmartEyeCount = weeSmartEyeCount + deviceAlarmSmallLogDo.getCount();
                    }else if (deviceAlarmSmallLogDo.getType().equals("7")) {
                        weeFireExtinguisherCount = weeFireExtinguisherCount + deviceAlarmSmallLogDo.getCount();
                    }else if (deviceAlarmSmallLogDo.getType().equals("20")) {
                        weeWaterImmersionCount = weeWaterImmersionCount + deviceAlarmSmallLogDo.getCount();
                    } else {
                        weeOtherCount = weeOtherCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weeFileCount", weeFileCount);
                map.put("weeWaterCount", weeWaterCount);
                map.put("weeSmokeCount", weeSmokeCount);
                map.put("weeOtherCount", weeOtherCount);
                map.put("weeGasCount", weeGasCount);
                map.put("weeSmartEyeCount", weeSmartEyeCount);
                map.put("weeFireExtinguisherEyeCount", weeFireExtinguisherCount);
                map.put("weeWaterImmersionCount", weeWaterImmersionCount);
                map.put("allCount", weeFileCount + weeWaterCount + weeSmokeCount + weeOtherCount + weeGasCount + weeSmartEyeCount + weeFireExtinguisherCount + weeWaterImmersionCount);
            }

        } else if (deviceClassify.equals("1")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todayVoltageCount = 0;//电压报警数目
                Integer todayCurrentCount = 0;//电流报警数目
                Integer todayTemperatureCount = 0;//温度报警数目
                Integer todayLeakageCurrentCount = 0;//漏电流报警数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电压报警"))) {
                        todayVoltageCount = todayVoltageCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电流报警"))) {
                        todayCurrentCount = todayCurrentCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("温度报警"))) {
                        todayTemperatureCount = todayTemperatureCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("漏电流报警"))) {
                        todayLeakageCurrentCount = todayLeakageCurrentCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todayVoltageCount", todayVoltageCount);
                map.put("todayCurrentCount", todayCurrentCount);
                map.put("todayTemperatureCount", todayTemperatureCount);
                map.put("todayLeakageCurrentCount", todayLeakageCurrentCount);
                map.put("allCount", todayVoltageCount + todayCurrentCount + todayTemperatureCount + todayLeakageCurrentCount);
                //百分比
                map.put("voltageProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayVoltageCount) * 100 / allCount, 2));
                map.put("currentProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayCurrentCount) * 100 / allCount, 2));
                map.put("temperatureProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayTemperatureCount) * 100 / allCount, 2));
                map.put("leakageCurrentProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayLeakageCurrentCount) * 100 / allCount, 2));
            } else {
                Integer allCount = 0;//总数目
                Integer weekVoltageCount = 0;//电压报警数目
                Integer weekCurrentCount = 0;//电流报警数目
                Integer weekTemperatureCount = 0;//温度报警数目
                Integer weekLeakageCurrentCount = 0;//漏电流报警数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电压报警"))) {
                        weekVoltageCount = weekVoltageCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电流报警"))) {
                        weekCurrentCount = weekCurrentCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("温度报警"))) {
                        weekTemperatureCount = weekTemperatureCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("漏电流报警"))) {
                        weekLeakageCurrentCount = weekLeakageCurrentCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weekVoltageCount", weekVoltageCount);
                map.put("weekCurrentCount", weekCurrentCount);
                map.put("weekTemperatureCount", weekTemperatureCount);
                map.put("weekLeakageCurrentCount", weekLeakageCurrentCount);
                map.put("allCount", weekVoltageCount + weekCurrentCount + weekTemperatureCount + weekLeakageCurrentCount);
            }
        } else if (deviceClassify.equals("2")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todayFireHydrantCount = 0;//消火栓数目
                Integer todayWaterSprayCount = 0;//自动水喷淋数目
                Integer todayPoolCount = 0;//消防水池数目
                Integer todaywaterTankCount = 0;//高位水箱数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("消火栓"))) {
                        todayFireHydrantCount = todayFireHydrantCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("末端试水装置"))) {
                        todayWaterSprayCount = todayWaterSprayCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("消防水池"))) {
                        todayPoolCount = todayPoolCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("高位消防水箱"))) {
                        todaywaterTankCount = todaywaterTankCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todayFireHydrantCount", todayFireHydrantCount);
                map.put("todayWaterSprayCount", todayWaterSprayCount);
                map.put("todayPoolCount", todayPoolCount);
                map.put("todaywaterTankCount", todaywaterTankCount);
                map.put("allCount", allCount);
                //map.put("allCount", todayFireHydrantCount + todayWaterSprayCount + todayPoolCount + todaywaterTankCount);
            } else {
                Integer allCount = 0;//总数目
                Integer weekHydraulicPressureCount = 0;//液压报警数目
                Integer weekLevelCount = 0;//液位报警数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("液压报警"))) {
                        weekHydraulicPressureCount = weekHydraulicPressureCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("液位报警"))) {
                        weekLevelCount = weekLevelCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weekHydraulicPressureCount", weekHydraulicPressureCount);
                map.put("weekLevelCount", weekLevelCount);
                map.put("allCount", weekHydraulicPressureCount + weekLevelCount);
            }
        } else if (deviceClassify.equals("3")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todaySmokeCount = 0;//独立烟感报警
                Integer todaySignalCount = 0;//信号异常报警
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("独立烟感报警"))) {
                        todaySmokeCount = todaySmokeCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("信号异常报警"))) {
                        todaySignalCount = todaySignalCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todaySmokeCount", todaySmokeCount);
                map.put("todaySignalCount", todaySignalCount);
                map.put("allCount", todaySmokeCount + todaySignalCount);
                //百分比
                map.put("smokeProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todaySmokeCount) * 100 / allCount, 2));
                map.put("signalProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todaySignalCount) * 100 / allCount, 2));
            } else {
                Integer allCount = 0;//总数目
                Integer weekSmokeCount = 0;//独立烟感报警
                Integer weekSignalCount = 0;//信号异常报警
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("独立烟感报警"))) {
                        weekSmokeCount = weekSmokeCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("信号异常报警"))) {
                        weekSignalCount = weekSignalCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weekSmokeCount", weekSmokeCount);
                map.put("weekSignalCount", weekSignalCount);
                map.put("allCount", weekSmokeCount + weekSignalCount);
            }
        } else if (deviceClassify.equals("4")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todayGasCount = 0;//可燃气报警
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("可燃气报警"))) {
                        todayGasCount = todayGasCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todayGasCount", todayGasCount);
                map.put("allCount", todayGasCount);
                //百分比
                map.put("gasProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayGasCount) * 100 / allCount, 2));
            } else {
                Integer allCount = 0;//总数目
                Integer weekGasCount = 0;//可燃气报警
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("可燃气报警"))) {
                        weekGasCount = weekGasCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weekGasCount", weekGasCount);
                map.put("allCount", weekGasCount);
            }
        } else if (deviceClassify.equals("5")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todaySystemEventCount = 0;//系统事件
                Integer todayFaultCount = 0;//故障
                Integer todayFireAlarmCount = 0;//火警
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("火警"))) {
                        todayFireAlarmCount = todayFireAlarmCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("故障"))) {
                        todayFaultCount = todayFaultCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("系统事件"))) {
                        todaySystemEventCount = todaySystemEventCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todaySystemEventCount", todaySystemEventCount);
                map.put("todayFaultCount", todayFaultCount);
                map.put("todayFireAlarmCount", todayFireAlarmCount);
                //map.put("allCount", todaySystemEventCount+todayFaultCount+todayFireAlarmCount);
                map.put("allCount", allCount);
                //百分比
                map.put("systemEventProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todaySystemEventCount) * 100 / allCount, 2));
                map.put("faulProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayFaultCount) * 100 / allCount, 2));
                map.put("fireAlarmProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayFireAlarmCount) * 100 / allCount, 2));
            } else {
                Integer allCount = 0;//总数目
                Integer todaySystemEventCount = 0;//系统事件
                Integer todayFaultCount = 0;//故障
                Integer todayFireAlarmCount = 0;//火警
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("火警"))) {
                        todayFireAlarmCount = todayFireAlarmCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("故障"))) {
                        todayFaultCount = todayFaultCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("系统事件"))) {
                        todaySystemEventCount = todaySystemEventCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todaySystemEventCount", todaySystemEventCount);
                map.put("todayFaultCount", todayFaultCount);
                map.put("todayFireAlarmCount", todayFireAlarmCount);
                //map.put("allCount", todaySystemEventCount + todayFaultCount + todayFireAlarmCount);
                map.put("allCount", allCount);
            }
        } else if (deviceClassify.equals("6")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todayFireCount = 0;//火焰报警
                Integer todayLeaveCount = 0;//脱岗离岗报警
                Integer todayPassWayCount = 0;//消防通道报警
                Integer todayElectricVehicleCount = 0;//电动车报警
                Integer todayPersonnelDetectionCount = 0;//人员检测
                Integer todayUnloadingAnalysisCount = 0;//卸油分析
                Integer todayAlertIdentificationCount = 0;//警戒识别
                Integer todayVideoOcclusionCount = 0;//视频遮挡

                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("火焰报警"))) {
                        todayFireCount = todayFireCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("脱岗离岗报警"))) {
                        todayLeaveCount = todayLeaveCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("消防通道报警"))) {
                        todayPassWayCount = todayPassWayCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电动车识别报警"))) {
                        todayElectricVehicleCount = todayElectricVehicleCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("人员检测"))) {
                        todayPersonnelDetectionCount = todayPersonnelDetectionCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("卸油分析"))) {
                        todayUnloadingAnalysisCount = todayUnloadingAnalysisCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("警戒识别"))) {
                        todayAlertIdentificationCount = todayAlertIdentificationCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("视频遮挡"))) {
                        todayVideoOcclusionCount = todayVideoOcclusionCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todayFireCount", todayFireCount);
                map.put("todayLeaveCount", todayLeaveCount);
                map.put("todayPassWayCount", todayPassWayCount);
                map.put("todayElectricVehicleCount", todayElectricVehicleCount);
                map.put("todayPersonnelDetectionCount", todayPersonnelDetectionCount);
                map.put("todayUnloadingAnalysisCount", todayUnloadingAnalysisCount);
                map.put("todayAlertIdentificationCount", todayAlertIdentificationCount);
                map.put("todayVideoOcclusionCount", todayVideoOcclusionCount);
                map.put("allCount", todayFireCount + todayLeaveCount + todayPassWayCount + todayElectricVehicleCount);
                //百分比
                map.put("fireProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayFireCount) * 100 / allCount, 2));
                map.put("leaveProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayLeaveCount) * 100 / allCount, 2));
                map.put("passWayProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayPassWayCount) * 100 / allCount, 2));
                map.put("electricVehicleProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayElectricVehicleCount) * 100 / allCount, 2));
            } else {
                Integer allCount = 0;//总数目
                Integer weekFireCount = 0;//火焰报警
                Integer weekLeaveCount = 0;//脱岗离岗报警
                Integer weekPassWayCount = 0;//消防通道报警
                Integer weekElectricVehicleCount = 0;//电动车报警
                Integer weekPersonnelDetectionCount = 0;//人员检测
                Integer weekUnloadingAnalysisCount = 0;//卸油分析
                Integer weekAlertIdentificationCount = 0;//警戒识别
                Integer weekVideoOcclusionCount = 0;//视频遮挡
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("火焰报警"))) {
                        weekFireCount = weekFireCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("脱岗离岗报警"))) {
                        weekLeaveCount = weekLeaveCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("消防通道报警"))) {
                        weekPassWayCount = weekPassWayCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电动车识别报警"))) {
                        weekElectricVehicleCount = weekElectricVehicleCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("人员检测"))) {
                        weekPersonnelDetectionCount = weekPersonnelDetectionCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("卸油分析"))) {
                        weekUnloadingAnalysisCount = weekUnloadingAnalysisCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("警戒识别"))) {
                        weekAlertIdentificationCount = weekAlertIdentificationCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("视频遮挡"))) {
                        weekVideoOcclusionCount = weekVideoOcclusionCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weekFireCount", weekFireCount);
                map.put("weekLeaveCount", weekLeaveCount);
                map.put("weekPassWayCount", weekPassWayCount);
                map.put("weekElectricVehicleCount", weekElectricVehicleCount);
                map.put("weekPersonnelDetectionCount", weekPersonnelDetectionCount);
                map.put("weekUnloadingAnalysisCount", weekUnloadingAnalysisCount);
                map.put("weekAlertIdentificationCount", weekAlertIdentificationCount);
                map.put("weekVideoOcclusionCount", weekVideoOcclusionCount);
                map.put("allCount", allCount);
            }
        } else if (deviceClassify.equals("11")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todayPersonnelDetectionCount = 0;//人员检测
                Integer todayUnloadingAnalysisCount = 0;//卸油分析
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("人员检测"))) {
                        todayPersonnelDetectionCount = todayPersonnelDetectionCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("卸油分析"))) {
                        todayUnloadingAnalysisCount = todayUnloadingAnalysisCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todayPersonnelDetectionCount", todayPersonnelDetectionCount);
                map.put("todayUnloadingAnalysisCount", todayUnloadingAnalysisCount);
                map.put("allCount", todayPersonnelDetectionCount + todayUnloadingAnalysisCount);
                //百分比
                map.put("personnelDetectionProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayPersonnelDetectionCount) * 100 / allCount, 2));
                map.put("unloadingAnalysisProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayUnloadingAnalysisCount) * 100 / allCount, 2));
            } else {
                Integer allCount = 0;//总数目
                Integer weekPersonnelDetectionCount = 0;//人员检测
                Integer weekUnloadingAnalysisCount = 0;//卸油分析
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("人员检测"))) {
                        weekPersonnelDetectionCount = weekPersonnelDetectionCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("卸油分析"))) {
                        weekUnloadingAnalysisCount = weekUnloadingAnalysisCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weekPersonnelDetectionCount", weekPersonnelDetectionCount);
                map.put("weekUnloadingAnalysisCount", weekUnloadingAnalysisCount);
                map.put("allCount", weekPersonnelDetectionCount + weekUnloadingAnalysisCount);
            }
        } else if (deviceClassify.equals("12")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todayElectricVehicleCount = 0;//电动车识别报警
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电动车识别报警"))) {
                        todayElectricVehicleCount = todayElectricVehicleCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todayElectricVehicleCount", todayElectricVehicleCount);
                map.put("allCount", todayElectricVehicleCount);
                //百分比
                map.put("electricVehicleProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayElectricVehicleCount) * 100 / allCount, 2));
            } else {
                Integer allCount = 0;//总数目
                Integer weekElectricVehicleCount = 0;//电动车报警
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电动车识别报警"))) {
                        weekElectricVehicleCount = weekElectricVehicleCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weekElectricVehicleCount", weekElectricVehicleCount);
                map.put("allCount", weekElectricVehicleCount);
            }
        } else if (deviceClassify.equals("13")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todayAlertIdentificationCount = 0;//警戒识别
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("警戒识别"))) {
                        todayAlertIdentificationCount = todayAlertIdentificationCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todayAlertIdentificationCount", todayAlertIdentificationCount);
                map.put("allCount", todayAlertIdentificationCount);
                //百分比
                map.put("alertIdentificationProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayAlertIdentificationCount) * 100 / allCount, 2));
            } else {
                Integer allCount = 0;//总数目
                Integer weekAlertIdentificationCount = 0;//警戒识别
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("警戒识别"))) {
                        weekAlertIdentificationCount = weekAlertIdentificationCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weekAlertIdentificationCount", weekAlertIdentificationCount);
                map.put("allCount", weekAlertIdentificationCount);
            }
        } else if (deviceClassify.equals("7")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todayPressureCount = 0;//压力报警数目
                Integer todayEmbezzlementCount = 0;//挪用报警数目
                Integer todayGasFireExtinguishingCount = 0;//气体灭火报警数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("手提灭火器"))) {
                        todayPressureCount = todayPressureCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("悬挂式灭火器"))) {
                        todayEmbezzlementCount = todayEmbezzlementCount + deviceAlarmSmallLogDo.getCount();
                    }else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("气体灭火系统"))) {
                        todayGasFireExtinguishingCount = todayGasFireExtinguishingCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todayPressureCount", todayPressureCount);
                map.put("todayEmbezzlementCount", todayEmbezzlementCount);
                map.put("todayGasFireExtinguishingCount", todayGasFireExtinguishingCount);
                map.put("allCount", todayPressureCount + todayEmbezzlementCount + todayGasFireExtinguishingCount);
                //百分比
                map.put("pressureProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayPressureCount) * 100 / allCount, 2));
                map.put("embezzlementProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayEmbezzlementCount) * 100 / allCount, 2));
            } else {
                Integer allCount = 0;//总数目
                Integer weekPressureCount = 0;//压力报警
                Integer weekEmbezzlementCount = 0;//挪用报警
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("压力报警"))) {
                        weekPressureCount = weekPressureCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("挪用报警"))) {
                        weekEmbezzlementCount = weekEmbezzlementCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weekPressureCount", weekPressureCount);
                map.put("weekEmbezzlementCount", weekEmbezzlementCount);
                map.put("allCount", weekPressureCount + weekEmbezzlementCount);
            }
        } else if (deviceClassify.equals("10")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todayVoltageCount = 0;//电压故障报警数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电压故障报警"))) {
                        todayVoltageCount = todayVoltageCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todayVoltageCount", todayVoltageCount);
                map.put("allCount", todayVoltageCount);
                //百分比
                map.put("voltageCount", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayVoltageCount) * 100 / allCount, 2));
            } else {
                Integer allCount = 0;//总数目
                Integer weekVoltageCount = 0;//电压故障报警数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电压故障报警"))) {
                        weekVoltageCount = weekVoltageCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weekVoltageCount", weekVoltageCount);
                map.put("allCount", weekVoltageCount);
            }
        }else if (deviceClassify.equals("20")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todayWaterImmersionCount = 0;//水浸报警数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("水浸告警"))) {
                        todayWaterImmersionCount = todayWaterImmersionCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todayVoltageCount", todayWaterImmersionCount);
                map.put("allCount", todayWaterImmersionCount);
                //百分比
                map.put("voltageCount", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayWaterImmersionCount) * 100 / allCount, 2));
            } else {
                Integer allCount = 0;//总数目
                Integer weekWaterImmersionCount = 0;//电压故障报警数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("水浸告警"))) {
                        weekWaterImmersionCount = weekWaterImmersionCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weekVoltageCount", weekWaterImmersionCount);
                map.put("allCount", weekWaterImmersionCount);
            }
        }else if (deviceClassify.equals("22")) {
            if (jsonParam.containsKey("todayAlarm")) {
                Integer allCount = 0;//总数目
                Integer todayVoltageCount = 0;//电压报警数目
                Integer todayCurrentCount = 0;//电流报警数目
                Integer todayTemperatureCount = 0;//温度报警数目
                Integer todayLeakageCurrentCount = 0;//漏电流报警数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电压报警"))) {
                        todayVoltageCount = todayVoltageCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电流报警"))) {
                        todayCurrentCount = todayCurrentCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("温度报警"))) {
                        todayTemperatureCount = todayTemperatureCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("漏电流报警"))) {
                        todayLeakageCurrentCount = todayLeakageCurrentCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("todayVoltageCount", todayVoltageCount);
                map.put("todayCurrentCount", todayCurrentCount);
                map.put("todayTemperatureCount", todayTemperatureCount);
                map.put("todayLeakageCurrentCount", todayLeakageCurrentCount);
                map.put("allCount", todayVoltageCount + todayCurrentCount + todayTemperatureCount + todayLeakageCurrentCount);
                //百分比
                map.put("voltageProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayVoltageCount) * 100 / allCount, 2));
                map.put("currentProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayCurrentCount) * 100 / allCount, 2));
                map.put("temperatureProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayTemperatureCount) * 100 / allCount, 2));
                map.put("leakageCurrentProportion", allCount == 0 ? 0 : NumberUtil.roundStr(((double) todayLeakageCurrentCount) * 100 / allCount, 2));
            } else {
                Integer allCount = 0;//总数目
                Integer weekVoltageCount = 0;//电压报警数目
                Integer weekCurrentCount = 0;//电流报警数目
                Integer weekTemperatureCount = 0;//温度报警数目
                Integer weekLeakageCurrentCount = 0;//漏电流报警数目
                for (DeviceAlarmSmallLogDo deviceAlarmSmallLogDo : twoList) {
                    if (deviceAlarmSmallLogDo.getType() == null) {
                        continue;
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电压报警"))) {
                        weekVoltageCount = weekVoltageCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("电流报警"))) {
                        weekCurrentCount = weekCurrentCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("温度报警"))) {
                        weekTemperatureCount = weekTemperatureCount + deviceAlarmSmallLogDo.getCount();
                    } else if (deviceAlarmSmallLogDo.getType().equals(keyMap.get("漏电流报警"))) {
                        weekLeakageCurrentCount = weekLeakageCurrentCount + deviceAlarmSmallLogDo.getCount();
                    }
                    allCount = allCount + deviceAlarmSmallLogDo.getCount();
                }
                map.put("weekVoltageCount", weekVoltageCount);
                map.put("weekCurrentCount", weekCurrentCount);
                map.put("weekTemperatureCount", weekTemperatureCount);
                map.put("weekLeakageCurrentCount", weekLeakageCurrentCount);
                map.put("allCount", weekVoltageCount + weekCurrentCount + weekTemperatureCount + weekLeakageCurrentCount);
            }
        }
        return map;
    }

    //查询今日表算统计数据
    public Map<String, Object> getTodayListForAllTwo(JSONObject jsonParam) {
        List<Map<String, Object>> insertList = new ArrayList<>();
        //日志表查询日期区间内的数据
        List<DeviceAlarmSmallLogDo> monthLogList = new ArrayList<>();
        List<UseDict> useDicts = null;
        List<DeviceType> deviceTypes = null;
        if (StrUtil.isBlank(jsonParam.getStr("deviceClassify"))) {
            jsonParam.put("table", "device_alarm_log_all_today");
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getAllLogForStatisticsTwo(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("1")) {
            jsonParam.put("table", "device_alarm_log_electric_fire_today");
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatisticsTwo(jsonParam);
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "电气火灾监测报警类型"));
        } else if (jsonParam.getStr("deviceClassify").equals("2")) {
            jsonParam.put("table", "device_alarm_log_fire_water_today");
            if (jsonParam.containsKey("todayAlarm")) {
                monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByDeviceTypeForStatisticsTwo(jsonParam);
                deviceTypes = deviceTypeMapper.selectList(new QueryWrapper<DeviceType>().eq("type", "2"));
            } else {
                monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatisticsTwo(jsonParam);
                useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "建筑消防用水报警类型"));
            }
        } else if (jsonParam.getStr("deviceClassify").equals("3")) {
            jsonParam.put("table", "device_alarm_log_smoke_today");
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "智慧独立烟感报警类型"));
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatisticsTwo(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("4")) {
            jsonParam.put("table", "device_alarm_log_gas_today");
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "可燃气体监测报警类型"));
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatisticsTwo(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("5")) {
            jsonParam.put("table", "device_alarm_log_auto_network_today");
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "自动联网报警类型"));
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatisticsTwo(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("6") || jsonParam.getStr("deviceClassify").equals("11") || jsonParam.getStr("deviceClassify").equals("12") || jsonParam.getStr("deviceClassify").equals("13") || jsonParam.getStr("deviceClassify").equals("14") || jsonParam.getStr("deviceClassify").equals("15") || jsonParam.getStr("deviceClassify").equals("16") || jsonParam.getStr("deviceClassify").equals("17")) {
            jsonParam.put("table", "device_alarm_log_visualization_today");
            String groupname = "";
            switch (jsonParam.getStr("deviceClassify")) {
                case "6":
                    groupname = "慧眼识别报警类型";
                    break;
                case "11":
                    groupname = "加油站报警类型";
                    break;
                case "12":
                    groupname = "智慧梯控报警类型";
                    break;
                case "13":
                    groupname = "智慧水域报警类型";
                    break;
//                case "14":
//                    groupname = "慧眼识别报警类型";
//                    break;
//                case "15":
//                    groupname = "慧眼识别报警类型";
//                    break;
                case "16":
                    groupname = "明厨亮灶报警类型";
                    break;
//                case "17":
//                    groupname = "慧眼识别报警类型";
//                    break;
            }
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", groupname));
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatisticsTwo(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("7")) {
            jsonParam.put("table", "device_alarm_log_fire_extinguisher_today");
            if (jsonParam.containsKey("todayAlarm")) {
                monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByDeviceTypeForStatisticsTwo(jsonParam);
                deviceTypes = deviceTypeMapper.selectList(new QueryWrapper<DeviceType>().eq("type", "7"));
            } else {
                monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatisticsTwo(jsonParam);
                useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "智能灭火器报警类型"));
            }
        } else if (jsonParam.getStr("deviceClassify").equals("10")) {
            jsonParam.put("table", "device_alarm_log_water_pump_today");
            if (jsonParam.containsKey("todayAlarm")) {
                monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByDeviceTypeForStatisticsTwo(jsonParam);
                deviceTypes = deviceTypeMapper.selectList(new QueryWrapper<DeviceType>().eq("type", "10"));
            } else {
                monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatisticsTwo(jsonParam);
                useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "水泵报警类型"));
            }
        }else if (jsonParam.getStr("deviceClassify").equals("22")) {
            jsonParam.put("table", "device_alarm_log_charging_station_today");
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getLogByAlarmTypeForStatisticsTwo(jsonParam);
            useDicts = useDictMapper.selectList(new QueryWrapper<UseDict>().eq("groupname", "电气火灾监测报警类型"));
        }
        Map<String, String> keyMap = new HashMap<>();
        if (useDicts != null) {
            for (UseDict use : useDicts) {
                keyMap.put(use.getName(), use.getId());
            }
        }
        if (deviceTypes != null) {
            for (DeviceType use : deviceTypes) {
                keyMap.put(use.getName(), use.getId());
            }
        }
        Map<String, Object> map = new HashMap<>();
        map = getMapByTwoList(monthLogList, map, jsonParam.getStr("deviceClassify"), keyMap, jsonParam);
        return map;
    }

    //通过周分析表获取数据
    public List<Map<String, Object>> getFromWeekStatistics(JSONObject jsonParam) {
        //日志表查询日期区间内的数据
        List<Map<String, Object>> monthLogList = new ArrayList<>();
        String type = jsonParam.getStr("type");
        if (StrUtil.isBlank(jsonParam.getStr("deviceClassify"))) {
            if ("1".equals(type)) {
                jsonParam.put("table", "device_alarm_log_all_statistics_week");
            } else if ("2".equals(type)) {
                jsonParam.put("table", "device_alarm_log_all_statistics_month");
            }
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getFromAllWeekStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("1")) {
            if ("1".equals(type)) {
                jsonParam.put("table", "device_alarm_log_electric_fire_statistics_week");
            } else if ("2".equals(type)) {
                jsonParam.put("table", "device_alarm_log_electric_fire_statistics_month");
            }
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getFromEleWeekStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("2")) {
            if ("1".equals(type)) {
                jsonParam.put("table", "device_alarm_log_fire_water_statistics_week");
            } else if ("2".equals(type)) {
                jsonParam.put("table", "device_alarm_log_fire_water_statistics_month");
            }
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getFromWaterWeekStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("3")) {
            if ("1".equals(type)) {
                jsonParam.put("table", "device_alarm_log_smoke_statistics_week");
            } else if ("2".equals(type)) {
                jsonParam.put("table", "device_alarm_log_smoke_statistics_month");
            }
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getFromSmokeWeekStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("4")) {
            if ("1".equals(type)) {
                jsonParam.put("table", "device_alarm_log_gas_statistics_week");
            } else if ("2".equals(type)) {
                jsonParam.put("table", "device_alarm_log_gas_statistics_month");
            }
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getFromGasWeekStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("5")) {
            if ("1".equals(type)) {
                jsonParam.put("table", "device_alarm_log_auto_network_statistics_week");
            } else if ("2".equals(type)) {
                jsonParam.put("table", "device_alarm_log_auto_network_statistics_month");
            }
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getFromAutoNetworkWeekStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("6")) {
            if ("1".equals(type)) {
                jsonParam.put("table", "device_alarm_log_visualization_statistics_week");
            } else if ("2".equals(type)) {
                jsonParam.put("table", "device_alarm_log_visualization_statistics_month");
            }
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getFromVisWeekStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("7")) {
            if ("1".equals(type)) {
                jsonParam.put("table", "device_alarm_log_fire_extinguisher_statistics_week");
            } else if ("2".equals(type)) {
                jsonParam.put("table", "device_alarm_log_fire_extinguisher_statistics_month");
            }
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getFromFireExtinguisherWeekStatistics(jsonParam);
        } else if (jsonParam.getStr("deviceClassify").equals("10")) {
            if ("1".equals(type)) {
                jsonParam.put("table", "device_alarm_log_water_pump_statistics_week");
            } else if ("2".equals(type)) {
                jsonParam.put("table", "device_alarm_log_water_pump_statistics_month");
            }
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getFromWaterPumpWeekStatistics(jsonParam);
        }else if (jsonParam.getStr("deviceClassify").equals("20")) {
            if ("1".equals(type)) {
                jsonParam.put("table", "device_alarm_log_water_immersion_statistics_week");
            } else if ("2".equals(type)) {
                jsonParam.put("table", "device_alarm_log_water_immersion_statistics_month");
            }
            monthLogList = deviceAlarmLogAllStatisticsWeekMapper.getFromWaterImmersionCountWeekStatistics(jsonParam);
        }
        return monthLogList;
    }

    //保存数据到统计
    public void insertList(List<Map<String, Object>> insertList, JSONObject jsonParam) {
        if (!insertList.isEmpty()) {
            //执行批量插入
            jsonParam.put("insertList", insertList);
            if (StrUtil.isBlank(jsonParam.getStr("deviceClassify"))) {
                if (jsonParam.getStr("table").equals("device_alarm_log_all_statistics_month")){
                    deviceAlarmLogAllStatisticsWeekMapper.insertZBM(jsonParam);
                }else {
                    deviceAlarmLogAllStatisticsWeekMapper.insertZB(jsonParam);
                }
            } else if (jsonParam.getStr("deviceClassify").equals("1")) {
                deviceAlarmLogAllStatisticsWeekMapper.insertEleZB(jsonParam);
            } else if (jsonParam.getStr("deviceClassify").equals("2")) {
                deviceAlarmLogAllStatisticsWeekMapper.insertWaterZB(jsonParam);
            } else if (jsonParam.getStr("deviceClassify").equals("3")) {
                deviceAlarmLogAllStatisticsWeekMapper.insertSmokeZB(jsonParam);
            } else if (jsonParam.getStr("deviceClassify").equals("4")) {
                deviceAlarmLogAllStatisticsWeekMapper.insertGasZB(jsonParam);
            } else if (jsonParam.getStr("deviceClassify").equals("5")) {
                deviceAlarmLogAllStatisticsWeekMapper.insertAutoNetworkZB(jsonParam);
            } else if (jsonParam.getStr("deviceClassify").equals("6")) {
                deviceAlarmLogAllStatisticsWeekMapper.insertVisZB(jsonParam);
            } else if (jsonParam.getStr("deviceClassify").equals("7")) {
                deviceAlarmLogAllStatisticsWeekMapper.insertFireExtinguisherZB(jsonParam);
            } else if (jsonParam.getStr("deviceClassify").equals("10")) {
                deviceAlarmLogAllStatisticsWeekMapper.insertWaterPumpZB(jsonParam);
            }else if (jsonParam.getStr("deviceClassify").equals("20")) {
                deviceAlarmLogAllStatisticsWeekMapper.insertWaterImmersionZB(jsonParam);
            }
        }
    }

    //删除不再用的数据:在月统计中的
    public void deleteDataForStatisticsMonth(JSONObject jsonObject) {
        jsonObject.put("table", "device_alarm_log_all_statistics_month");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForMonth(jsonObject);
        jsonObject.put("table", "device_alarm_log_electric_fire_statistics_month");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForMonth(jsonObject);
        jsonObject.put("table", "device_alarm_log_fire_water_statistics_month");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForMonth(jsonObject);
        jsonObject.put("table", "device_alarm_log_gas_statistics_month");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForMonth(jsonObject);
        jsonObject.put("table", "device_alarm_log_smoke_statistics_month");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForMonth(jsonObject);
        jsonObject.put("table", "device_alarm_log_visualization_statistics_month");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForMonth(jsonObject);
        jsonObject.put("table", "device_alarm_log_fire_extinguisher_statistics_month");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForMonth(jsonObject);
        jsonObject.put("table", "device_alarm_log_auto_network_statistics_month");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForMonth(jsonObject);
        jsonObject.put("table", "device_alarm_log_water_pump_statistics_month");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForMonth(jsonObject);
        jsonObject.put("table", "device_alarm_log_water_immersion_statistics_month");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForMonth(jsonObject);
        jsonObject.put("table", "device_alarm_log_charging_station_statistics_month");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForMonth(jsonObject);
    }

    //删除不再用的数据:在周统计中的
    public void deleteDataForStatisticsWeek(JSONObject jsonObject) {
        jsonObject.put("table", "device_alarm_log_all_statistics_week");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForWeek(jsonObject);
        jsonObject.put("table", "device_alarm_log_electric_fire_statistics_week");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForWeek(jsonObject);
        jsonObject.put("table", "device_alarm_log_fire_water_statistics_week");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForWeek(jsonObject);
        jsonObject.put("table", "device_alarm_log_gas_statistics_week");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForWeek(jsonObject);
        jsonObject.put("table", "device_alarm_log_smoke_statistics_week");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForWeek(jsonObject);
        jsonObject.put("table", "device_alarm_log_visualization_statistics_week");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForWeek(jsonObject);
        jsonObject.put("table", "device_alarm_log_fire_extinguisher_statistics_week");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForWeek(jsonObject);
        jsonObject.put("table", "device_alarm_log_auto_network_statistics_week");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForWeek(jsonObject);
        jsonObject.put("table", "device_alarm_log_water_pump_statistics_week");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForWeek(jsonObject);
        jsonObject.put("table", "device_alarm_log_water_immersion_statistics_week");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForWeek(jsonObject);
        jsonObject.put("table", "device_alarm_log_charging_station_statistics_week");
        deviceAlarmLogAllStatisticsWeekMapper.deleteStatisticsForWeek(jsonObject);
    }

    //删除今日表中的昨日的数据
    public void deleteTodayLog(JSONObject jsonObject) {
        jsonObject.put("table", "device_alarm_log_all_today");
        deviceAlarmLogAllStatisticsWeekMapper.deleteTodayLog(jsonObject);
        jsonObject.put("table", "device_alarm_log_electric_fire_today");
        deviceAlarmLogAllStatisticsWeekMapper.deleteTodayLog(jsonObject);
        jsonObject.put("table", "device_alarm_log_fire_water_today");
        deviceAlarmLogAllStatisticsWeekMapper.deleteTodayLog(jsonObject);
        jsonObject.put("table", "device_alarm_log_gas_today");
        deviceAlarmLogAllStatisticsWeekMapper.deleteTodayLog(jsonObject);
        jsonObject.put("table", "device_alarm_log_smoke_today");
        deviceAlarmLogAllStatisticsWeekMapper.deleteTodayLog(jsonObject);
        jsonObject.put("table", "device_alarm_log_visualization_today");
        deviceAlarmLogAllStatisticsWeekMapper.deleteTodayLog(jsonObject);
        jsonObject.put("table", "device_alarm_log_fire_extinguisher_today");
        deviceAlarmLogAllStatisticsWeekMapper.deleteTodayLog(jsonObject);
        jsonObject.put("table", "device_alarm_log_auto_network_today");
        deviceAlarmLogAllStatisticsWeekMapper.deleteTodayLog(jsonObject);
        jsonObject.put("table", "device_alarm_log_water_pump_today");
        deviceAlarmLogAllStatisticsWeekMapper.deleteTodayLog(jsonObject);
        jsonObject.put("table", "device_alarm_log_water_immersion_today");
        deviceAlarmLogAllStatisticsWeekMapper.deleteTodayLog(jsonObject);
        jsonObject.put("table", "device_alarm_log_electric_fire_today");
        deviceAlarmLogAllStatisticsWeekMapper.deleteTodayLog(jsonObject);
    }

    public static void main(String[] args) {
        System.out.println(DayUtil.getPastDate(6));
    }


}
